package com.lab.mapper;

import com.github.pagehelper.Page;
import com.lab.dto.DailyPageQueryDTO;
import com.lab.entity.DailyProgressContent;
import com.lab.entity.MemberDailyProgress;
import com.lab.vo.DailyProgressVO;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface DailyMemberProgressMapper {


    /**
     * 分页查询成员每日进度
     * @param queryDTO 分页及查询条件DTO
     * @return 分页结果
     */
    Page<DailyProgressContent> pageQuery(DailyPageQueryDTO queryDTO);


    DailyProgressVO getById(Long id);


    List<DailyProgressVO> getByRoleType(String roleType);
    List<DailyProgressVO> getByMemberName(@Param("memberName") String memberName);

    List<DailyProgressVO> getByProgressDate(@Param("progressDate") LocalDate progressDate);
    @Insert("INSERT INTO member_daily_progress (member_id, progress_date, role_type) " +
            "VALUES (#{memberId}, #{progressDate}, #{roleType})")
    @Options(useGeneratedKeys = true, keyProperty = "id") // 获取自增ID
    void insertMain(MemberDailyProgress main);

    // 新增日进度内容表记录（单条）
    @Insert("INSERT INTO daily_progress_content (progress_id, content_date, content) " +
            "VALUES (#{progressId}, #{contentDate}, #{content})")
    void insertContent(DailyProgressContent content);


    void deleteByUserName(String username);
    // 禁用外键约束
        void disableForeignKeyChecks();

    // 启用外键约束
        void enableForeignKeyChecks();

    // 清空 daily_progress_content 表
        void truncateDailyContent();

        // 清空 member_daily_progress 表
        void truncateMemberProgress();

}